# Maintainer: Antonio Rojas <arojas@archlinux.org>
# Contributor: Guillaume Horel <guillaume.horel@gmail.com>

_pyname=ecos-python
pkgname=python-ecos
pkgver=2.0.11
pkgrel=2
pkgdesc='Python interface for ECOS'
url='https://github.com/embotech/ecos-python'
depends=(python-scipy ecos)
makedepends=(python-build python-installer python-wheel)
checkdepends=(python-nose python-pytest)
license=(GPL3)
arch=(loong64 x86_64)
source=(https://github.com/embotech/ecos-python/archive/v$pkgver/$pkgname-$pkgver.tar.gz
        unbundle-ecos.patch)
sha256sums=('01ebd3fc8a54822e035c5d69f750fc577001754a057a6a023b68e736c43a7823'
            'c929cbe71cf8a109a66cbc681c6c501c42517b44e63f88440c36e5c7ca9e3be9')

prepare() {
  cd $_pyname-$pkgver
  patch -p1 -i ../unbundle-ecos.patch
}

build() {
  cd $_pyname-$pkgver
  python -m build --wheel --no-isolation --skip-dependency-check
}

check() {
  cd $_pyname-$pkgver
  python -m venv --system-site-packages test-env
  test-env/bin/python -m installer dist/*.whl
  test-env/bin/python -m pytest -v
}

package() {
  cd $_pyname-$pkgver
  python -m installer --destdir="$pkgdir" dist/*.whl
}
